package cn.edu.nuc.ssm.dao;

import cn.edu.nuc.ssm.entity.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface AdminMapper {
    @Delete({
        "delete from admin",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into admin ( username, ",
        "password, type)",
        "values ( #{username,jdbcType=VARCHAR}, ",
        "#{password,jdbcType=VARCHAR}, 1)"
    })
    int insert(Admin record);

    int insertSelective(Admin record);

    @Select({
        "select",
        "id, username, password, type",
        "from admin",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("cn.edu.nuc.ssm.dao.AdminMapper.BaseResultMap")
    Admin selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Admin record);

    @Update({
        "update admin",
        "set username = #{username,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "type = 1",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Admin record);

    @Select({
            "select",
            "id, username, password, type",
            "from admin",
            "limit #{start,jdbcType=INTEGER},#{offset,jdbcType=INTEGER}"
    })
    List<Admin> findPageList(@Param("start") int start,@Param("offset") int offset);


    List<Admin> findbyUsernameandpassword(@Param("username")String username,@Param("password")String password);

    Admin findbyId(@Param("id")Integer id);


    int updatePasswordbyId(@Param("updatedPassword")String updatedPassword,@Param("id")Integer id);


    List<Admin> findbyUsername(@Param("username")String username);

    List<Admin> find();



}